package com.bobi.tfca.model.vo;

import cn.hutool.core.bean.BeanUtil;
import com.bobi.tfca.model.entity.ArticleEntity;
import com.bobi.tfca.model.entity.ParagraphEntity;
import com.bobi.tfca.utils.DateTimeUtil;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serial;
import java.io.Serializable;
import java.time.LocalDateTime;
import java.util.List;

/**
 * @author 李文发
 * @date 2024/4/13
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
@ApiModel(value = "文章")
public class ArticleVO implements Serializable {

    @Serial
    private static final long serialVersionUID = -2982357686917896230L;

    @ApiModelProperty(value = "文章id")
    // 文章id
    private Integer articleId;
    @ApiModelProperty(value = "文章标题")
    // 文章标题
    private String title;
    @ApiModelProperty(value = "文章类型")
    // 文章类型
    private Integer category;
    @ApiModelProperty(value = "作者id")
    // 作者id
    private Integer authorId;
    @ApiModelProperty(value = "发布时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    // 发布时间
    private LocalDateTime releaseTime;
    @ApiModelProperty(value = "点赞数")
    // 点赞数
    private Integer likes;
    @ApiModelProperty(value = "封面图片")
    // 封面图片
    private String outsidePicture;
    @ApiModelProperty(value = "文章状态（0：草稿，1：待审核，2：已发布，3：已删除）")
    // 文章状态（0：草稿，1：待审核，2：已发布，3：已删除）
    private Integer articleStatus;
    @ApiModelProperty(value = "作者名称")
    // 作者名称
    private String authorName;
    @ApiModelProperty(value = "段落列表")
    // 段落列表
    private List<ParagraphEntity> paragraphList;
    @ApiModelProperty(value = "当前用户是否点赞")
    private Boolean isLiked;

    public static ArticleEntity ofArticleVO(ArticleVO articleVO) {
        ArticleEntity entity = new ArticleEntity();
        BeanUtil.copyProperties(articleVO, entity);
        entity.setArticleId(null);
        return entity;
    }
}
